package com.irdstudio.biz.drools.common;

import java.io.Serializable;
import java.math.BigDecimal;

public class BigDecimalSumAccumulateFunction extends org.drools.core.base.accumulators.BigDecimalSumAccumulateFunction{

    @Override
    public void accumulate(Serializable context,
                           Object value) {
        SumData data = (SumData) context;
        if (value == null) {
            value = "0";
        }
        String num = value.toString();
        num = num.replaceAll(",", "");
        data.total = data.total.add( new BigDecimal(num) );
    }
}
